<script setup lang="ts">
  import { Persistent } from '@/utils/cache/persistent';
  import { TOKEN_KEY } from '@/enums/cacheEnum';
  import { PageWrapper } from '@/components/Page';
  import { useMessage } from '@/hooks/web/useMessage';
  import { ref, unref } from 'vue';
  import { copyText } from '@/utils/copyTextToClipboard';
  import UploadOssTest from '@/views/zhm/UploadOssTest.vue';

  const token = ref<string>(Persistent.getLocal(TOKEN_KEY));

  const { createMessage } = useMessage();

  function handleCopy() {
    const value = unref(token);
    if (!value) {
      createMessage.warning('请输入要拷贝的内容！');
      return;
    }
    copyText(value);
  }
</script>

<template>
  <PageWrapper title="token">
    <div class="flex justify-center h-xs">
      <a-textarea v-model:value="token" allow-clear />
      <a-button type="primary" @click="handleCopy"> Copy</a-button>
    </div>
    <UploadOssTest />
  </PageWrapper>
</template>

<style scoped lang="less"></style>
